﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;

namespace DusonFramework.Core
{
    public sealed class Conversion
    {
        /// <summary>
        /// Convert enumerator to List
        /// </summary>
        /// <param name="en">the enumerator</param>
        /// <returns></returns>
        public static List<ReturnElementType> ToObjectList<ReturnElementType>(IEnumerator en)
        {
            List<ReturnElementType> list = new List<ReturnElementType>();
            while (en.MoveNext())
            {
                list.Add((ReturnElementType)en.Current);
            }
            return list;
        }

        public static List<T> ConvertArrayToList<T>(T[] arr)
        {
            List<T> list = new List<T>();
            if (arr != null && arr.Length > 0)
            {
                for (int i = 0; i < arr.Length; ++i)
                    list.Add(arr[i]);
            }

            return list;
        }

    }
}
